#include <string.h>
#include <iostream>
using std::cout;
using std::endl;

class Computer{
public:
    Computer(const char * brand,double price)
    : _brand(new char[strlen(brand) + 1]())
    , _price(price)
    {
        strcpy(_brand,brand);
        cout << "Computer(const char *,double)" << endl;
    }

    void print(){
        cout << "brand:" << _brand << endl
            << "price:" << _price << endl;
    }

    ~Computer(){
        if(_brand){
            delete [] _brand;
            _brand = nullptr;
        }
        cout << "~Computer()" << endl;
    }
private:
    char * _brand;
    double _price;
};

Computer pc("ASUS",6400);

void test0(){
    Computer pc2("Apple",12888);
    static Computer pc3("HP",7889);
    Computer * p1 = new Computer("Thinkpad",9999);
    delete p1;
}

int main(void){
    test0();
    cout << "over" << endl;
    return 0;
}
